package com.educate.common.web;

public class R<DATA> {

    public static final String CODE_LOGIN_EXPIRE = "8001";//登录已过期
    public static final String CODE_LOGIN_NOT = "8002";//没有登录

    private String code;
    private String msg;
    private DATA data;

    public R() {
    }

    public R(String code, String msg, DATA data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public DATA getData() {
        return data;
    }

    public void setData(DATA data) {
        this.data = data;
    }

    public static <DATA> R<DATA> ok() {
        return new R<>("000000", "success", null);
    }

    public static <DATA> R<DATA> ok(DATA data) {
        return new R<>("000000", "success", data);
    }

    public static <DATA> R<DATA> error(String msg) {
        return new R<>("999999", msg, null);
    }

    public static <DATA> R<DATA> error(String code, String msg) {
        return new R<>(code, msg, null);
    }
}
